package org.madgecko.basic.controller;

import org.madgecko.basic.util.EnumUtils;
import org.madgecko.basic.model.EnumComboObj;
import org.madgecko.basic.model.ExtGridReturn;
import org.madgecko.basic.model.enumeration.ChannelType;
import org.madgecko.basic.model.enumeration.ExamGenType;
import org.madgecko.basic.model.enumeration.ExamType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin/enum")
public class EnumController {

	@ResponseBody
	@RequestMapping(value = "/channelType", produces={"application/json; charset=UTF-8"})
	public Object listChannelType(){
		List<Object> lo = EnumUtils.enum2ObjList(ChannelType.class, "name", EnumComboObj.class, "display", "value");
		return new ExtGridReturn((long)lo.size(), lo);
	}

	@ResponseBody
	@RequestMapping(value = "/examGenType", produces={"application/json; charset=UTF-8"})
	public Object listExamGenType(){
		List<Object> lo = EnumUtils.enum2ObjList(ExamGenType.class, "name", EnumComboObj.class, "display", "value");
		return new ExtGridReturn((long)lo.size(), lo);
	}

	@ResponseBody
	@RequestMapping(value = "/examType", produces={"application/json; charset=UTF-8"})
	public Object listExamType(){
		List<Object> lo = EnumUtils.enum2ObjList(ExamType.class, "name", EnumComboObj.class, "display", "value");
		return new ExtGridReturn((long)lo.size(), lo);
	}
}
